package com.example.dbdoc.exception;

/**
 * 数据库文档生成异常类
 * 
 * @author 系统生成
 * @version 1.0.0
 */
public class DatabaseDocException extends RuntimeException {

    private static final long serialVersionUID = 1754710374222155728L;

    private final String errorCode;
    
    public DatabaseDocException(String message) {
        super(message);
        this.errorCode = "UNKNOWN";
    }
    
    public DatabaseDocException(String errorCode, String message) {
        super(message);
        this.errorCode = errorCode;
    }
    
    public DatabaseDocException(String message, Throwable cause) {
        super(message, cause);
        this.errorCode = "UNKNOWN";
    }
    
    public DatabaseDocException(String errorCode, String message, Throwable cause) {
        super(message, cause);
        this.errorCode = errorCode;
    }
    
    public String getErrorCode() {
        return errorCode;
    }
    
    /**
     * 数据库连接异常
     */
    public static class DatabaseConnectionException extends DatabaseDocException {
        public DatabaseConnectionException(String message, Throwable cause) {
            super("DB_CONNECTION_ERROR", "数据库连接失败: " + message, cause);
        }
    }
    
    /**
     * 元数据读取异常
     */
    public static class MetadataReadException extends DatabaseDocException {
        public MetadataReadException(String tableName, String message, Throwable cause) {
            super("METADATA_READ_ERROR", "读取表 " + tableName + " 的元数据失败: " + message, cause);
        }
    }
    
    /**
     * 文档生成异常
     */
    public static class DocumentGenerationException extends DatabaseDocException {
        public DocumentGenerationException(String message, Throwable cause) {
            super("DOC_GENERATION_ERROR", "文档生成失败: " + message, cause);
        }
    }
    
    /**
     * 文件操作异常
     */
    public static class FileOperationException extends DatabaseDocException {
        public FileOperationException(String filePath, String message, Throwable cause) {
            super("FILE_OPERATION_ERROR", "文件操作失败 [" + filePath + "]: " + message, cause);
        }
    }
}